package com.example.thirdannotation.y2024;

import com.example.thirdannotation.y2024.bean.Person2;
import com.example.thirdannotation.y2024.config.ConfigOfPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

public class ConfigOfPropertyValuesTest {
    public static void main(String[] args) {
        // 创建容器
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(ConfigOfPropertyValues.class);
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println("beanDefinitionName-->"+beanDefinitionName);
        }
        Person2 person =  applicationContext.getBean(Person2.class);
        System.out.println("person-->"+person);

        ConfigurableEnvironment environment = applicationContext.getEnvironment();
        String nickName = environment.getProperty("person.nickName");
        System.out.println("nickName-->"+nickName);
    }

}

